<template>
  <div class="data-v-sq" :style="style">
    <div class="value" :style="valueStyle">{{ value }}</div>
    <div class="name" :style="valueStyle">{{ name }}</div>
  </div>
</template>

<script>
export default {
  name: "data-v-summary-square",
  props: {
    value: {
      type: [String, Number],
      default: 0
    },
    name: {
      type: String,
      default: "默认数据名称"
    },
    type: {
      type: [String, Number],
      default: 1
    },
    color: {
      type: String,
      default: "#fff"
    }
  },

  computed: {
    style() {
      let imgsrc = require(`./img/${this.type}.png`);
      return {
        background: `url(${imgsrc}) no-repeat center center`,
        backgroundSize: "contain"
      };
    },
    valueStyle() {
      return {
        color: this.color
      };
    }
  }
};
</script>

<style lang="less">
.data-v-sq {
  position: relative;
  width: 90px;
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 5px;
  .name {
    opacity: 0.5;
    font-size: 14px;
  }
  .value {
    font-size: 18px;
  }
}
</style>
